Skip to content

Conversation

@yyihuang
Copy link
Contributor

@yyihuang yyihuang commented Jan 23, 2026

flashinfer_trace/tests/references/test_dsa_sparse_attention_h16_ckv512_kpe64_topk256_ps1.py: todo
flashinfer_trace/tests/references/test_dsa_sparse_attention_h16_ckv512_kpe64_topk256_ps64.py: todo
flashinfer_trace/tests/references/test_dsa_vs_definition_reference.py: todo

flashinfer_trace/tests/references/test_gdn_decode_qk16_v32_d128_k_last.py: ✅
flashinfer_trace/tests/references/test_gdn_prefill_qk16_v32_d128_k_last.py: ✅

flashinfer_trace/tests/references/test_gqa_paged_decode_h32_kv4_d128_ps1.py: ✅
flashinfer_trace/tests/references/test_gqa_paged_decode_h32_kv4_d128_ps64.py: ✅
flashinfer_trace/tests/references/test_gqa_paged_decode_h32_kv8_d128_ps1.py: ✅
flashinfer_trace/tests/references/test_gqa_paged_decode_h32_kv8_d128_ps64.py: ✅

flashinfer_trace/tests/references/test_gqa_paged_prefill_h32_kv4_d128_ps1.py: todo

@coderabbitai
Copy link

coderabbitai bot commented Jan 23, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @yyihuang, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on a significant refactoring effort across the reference test suite. The core objective is to enhance the maintainability and readability of the tests by extracting common patterns and utilities into a dedicated test_utils.py module. This change standardizes how reference implementations are loaded and executed, how test inputs are generated, and how results are compared, leading to a cleaner and more efficient testing framework for attention mechanisms, normalization, and sampling operations.

Highlights

  • Centralized Test Utilities: A new module, test_utils.py, has been introduced to centralize common functionalities for loading reference implementations, generating random inputs, and comparing tensors across various tests. This significantly reduces code duplication and improves maintainability.
  • Test Code Simplification: The run functions, which previously contained the reference implementations, have been removed from individual test files. These implementations are now loaded dynamically from definition files using the new get_reference_run utility.
  • Standardized Input Generation: Test input generation functions (generate_random_inputs) in many files have been simplified by removing redundant parameters and leveraging centralized constant definitions, making them more concise and consistent.
  • Streamlined Comparison Logic: The tensor comparison and error reporting logic within individual test functions has been streamlined, relying on the new utility functions for a more standardized and less verbose approach.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request is a significant and valuable refactoring of the reference tests. It successfully centralizes the reference implementations into definition files and introduces a test_utils.py module to reduce code duplication across test files. This greatly improves the maintainability and clarity of the test suite. The changes are well-executed, but I've identified a critical issue in one of the refactored tests that needs to be addressed.

Comment on lines 29 to 31
sparse_indices = torch.randint(
0, total_tokens_in_cache, (num_tokens, topk), dtype=torch.int32, device=device
0, num_pages, (num_tokens, topk), dtype=torch.int32, device=device
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The sparse_indices are being generated with an incorrect upper bound. For page_size=64, the reference implementation expects token-level indices, but torch.randint is being called with num_pages as the upper bound, which generates page-level indices. This will cause the test to use incorrect inputs, potentially leading to incorrect validation.

The upper bound should be the total number of tokens in the cache (num_pages * PAGE_SIZE).

Comment on lines 93 to 95
sparse_indices[t, :valid_count] = torch.randint(
0, total_tokens_in_cache, (valid_count,), dtype=torch.int32, device=device
0, num_pages, (valid_count,), dtype=torch.int32, device=device
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

Similar to the issue in generate_random_inputs, the sparse_indices for the padding test are being generated with an incorrect upper bound. It should be the total number of tokens in the cache, not the number of pages. The reference implementation expects token-level indices when page_size > 1.

You should calculate total_tokens_in_cache = num_pages * PAGE_SIZE before the loop and use it as the upper bound for torch.randint here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants